# 移动
def move(annulus, f,  m, t):
    msg = '环 ' + str(annulus) + 'from 柱 ' + f + 'to 柱 ' + t + '\r\n'
    tip = 'press [Enter] to continue...'
    if (annulus == 1):
        input(tip)
        yield msg
    else:
        # 把 环 n-1从原柱放到中间柱
        yield from move(annulus=annulus-1, f=f, m=t, t=m)
        input(tip)
        # 把 环 n 移动到目标
        yield msg
        # 把刚才挪走的环（n-1）移动到目标
        yield from move(annulus=annulus-1, f=m, m=f, t=t)


# 执行
def run():
    steps = 0
    for i in move(annulus=3, f='A', m='C', t='B'):
        print(i)
        steps = steps+1

    print('Total move ['+str(steps)+'] steps.\r\n')


run()
